<template>
  <base-layout>
    <el-col :span="14">入库配件列表</el-col>
    <template #searchPanel>
      <search-panel
        :addPer="'111'"
        :selectPer="'111'"
        @search="search"
        :showSearchButton="true"
        :showAddButton="false"
      >
        <span style="margin-left: -720px; display: block">入库配件列表</span>
        <el-select
          clearable
          style="width: 200px"
          v-model="form.partsDictId"
          placeholder="配件类别"
        >
          <el-option
            v-for="item in dict['汽车配件类型']"
            :key="item.id"
            :value="item.value"
            :label="item.text"
          />
        </el-select>
        <el-input
          v-model="form.likeName"
          clearable
          placeholder="配件编号/配件名称"
          style="width: 200px"
        />
      </search-panel>
    </template>

    <template #contentPanel>
      <data-table
        :value="tableData"
        :total-count="totalCount"
        :table-column-attributes="tableColumnAttributes"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :width="160"
      >
      </data-table>
    </template>
  </base-layout>
</template>

<script>
import { storageSitePartsPage } from "@/api/after-sale/storehouseManage/inStockManage";
import baseMixin from "@/mixins/base";
import { getDict } from "@/utils";

export default {
  name: "carInfo",
  components: {},
  props: {
    storageSiteId: {},
    stockId: {},
  },
  mixins: [
    baseMixin({
      idName: "id",
      findData: storageSitePartsPage,
      dataName: ["content", "totalRecords"],
      format(res) {
        return res.map((data) => {
          return data;
        });
      },
    }),
  ],
  data() {
    return {
      form: {},
      tableColumnAttributes: [
        { name: "库存编号", value: "stockCode", type: "text" },
        { name: "配件编号", value: "partsCode", type: "text" },
        { name: "配件名称", value: "partsName", type: "text" },
        { name: "配件类别", value: "partsType", type: "text" },
        { name: "配件单位", value: "partsUnit", type: "text" },
        { name: "配件来源", value: "source", type: "text" },
        { name: "配件仓位", value: "storageSiteName", type: "text" },
        { name: "仓位编号", value: "storageSiteCode", type: "text" },
        { name: "采购成本", value: "purchasePrice", type: "text" },
        { name: "库房标价", value: "storagePrice", type: "text" },
        { name: "入库时间", value: "createTime", type: "text" }
      ],
    };
  },
  methods: {
    search() {
      this.searchOptions = this.form;
      this.currentPage = 1;
      this.setTableData();
    },
  },
  created() {
    this.searchOptions.stockId = this.stockId;
    this.searchOptions.storageSiteId = this.storageSiteId;
    this.form.stockId = this.stockId;
    this.form.storageSiteId = this.storageSiteId;
    this.dict = getDict(["汽车配件类型"], this.form.storeId);
  },
};
</script>

<style lang="scss" scoped>
.el-table .delete-row {
  background: #f5f7fa;
  color: #ccc !important;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 80px;
  height: 80px;
  display: block;
}
</style>
